<?php
session_start();
$_SESSION['autorizzato'] = 'no';
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="apple-touch-startup-image" href="img/splash.png" />  
        <meta name="apple-mobile-web-app-capable" content="yes" />  
        <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />  
        <meta name="viewport" content="width=device-width, user-scalable=no">               
        <!--<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.3.0/pure-min.css">-->
         <link rel="stylesheet" href="css/pure-min.css">
        <!--[if lte IE 8]>
        <link rel="stylesheet" href="css/main-grid-old-ie.css">
    <![endif]-->
        <!--[if gt IE 8]><!-->
        <link rel="stylesheet" href="css/main-grid.css">
        <!--<![endif]-->

        <!--[if lte IE 8]>
            <link rel="stylesheet" href="css/layouts/marketing-old-ie.css">
        <![endif]-->
        <!--[if gt IE 8]><!-->
        <link rel="stylesheet" href="css/layouts/marketing.css">
        <!--<![endif]-->
        <!--<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css">-->
<link rel="stylesheet" href="css/font-awesome.css">
        <link rel="apple-touch-icon-precomposed" href="img/icon.png"/>
        <link rel="apple-touch-icon" href="img/icon.png"/>  
        <script src="js/jquery-2.1.0.js" type="text/javascript"></script>
        <title></title>
    </head>
    <body>
        <div class="header">
            <div class="home-menu pure-menu pure-menu-open pure-menu-horizontal pure-menu-fixed">                
                <ul>              
                    <li><a href="#login">Accedi</a></li>
                </ul>
            </div>
        </div>
        <div class="splash-container">
            <div class="splash">
                <h1 class="splash-head">SCHEDA CONTATTO</h1>
                <p class="splash-subhead">
                    TRASCINA SU PER ACCEDERE
                </p>
            </div>
        </div>
        <div class="content-wrapper">
            <h2 class="content-head is-center">Inserisci le credenziali di accesso.</h2>
            <div class="pure-g">
                <div class="l-box-lrg pure-u-1 pure-u-med-2-5">
                    <!--                    <form class="pure-form pure-form-stacked">
                                            <fieldset id="accesso">
                                                <div class="pure-control-group">  
                                                    <input id="login" name="login" type="text" placeholder="Login" required>     
                                                    <input id="password" name="password" type="password" placeholder="Password" required>   
                                                    <button id="login_button" class="pure-button pure-button-primary" onclick="login()" >ENTRA</button>
                                                    
                                                </div>
                                            </fieldset></form>  -->
                    <div class="pure-form pure-form-stacked">  
                        <input id="login" name="login" type="text" placeholder="Login" required>     
                        <input id="password" name="password" type="password" placeholder="Password" required>   
                        <button id="login_button" class="pure-button pure-button-primary" onclick="login()" >ENTRA</button>

                    </div>
                </div>

            </div>
        </div>        
        <script type="text/javascript">
            function login() {
                {
                    var login = $.trim($("#login").val());
                    var password = $.trim($("#password").val());
                    console.log('login ' + login);
                    console.log('password ' + password);
                    $.ajax({
                      type: "POST",
                      //url: "http://www.ramaeventi.it/rama_booking/auth.php",
                      url: "http://localhost/rama_booking/auth.php",
                      data: ({login: login, password: password}),
                      cache: false,
                      dataType: "text",
                      success: onSuccess
                    });                                                            
                    console.log('qui');
                    return false;
                }
            }
            function onSuccess(data) {
                console.log('chiamata ok');
                var msg = data;   
                console.log('messaggio di risposta...');
                console.log(msg);
                if (msg === '1') {
                    console.log('Chiamata ok con msg ' + msg );
                    var url = "welcome.php";
                    $(location).attr('href', url);
                } else if (msg === '0') {
                    console.log('Password errata');
                    alert('Password errata');
                }
            }            
        </script>
    </body>
</html>